﻿using System;
using System.Linq;

namespace Daemon.Data.Substructure.Framework.Extension
{
	public static class UriExtensions
	{
		public static Uri Append(this Uri uri, params string[] paths)
		{
			return new Uri(paths.Aggregate(uri.AbsoluteUri, (current, path) => string.Format("{0}/{1}", current.TrimEnd('/'), path.TrimStart('/'))));
		}

		public static Uri Include(this Uri uri, params string[] paths)
		{
			Uri newUri = uri;
			foreach (var path in paths)
			{
				newUri = new Uri(newUri, path);
			}

			return newUri;
		}
	}
}
